<?php
class Home extends Frontend_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->Model(array("Marticle"));
	}	
	
	public function index(){
		$this->parser->parse("home/index.tpl", NULL);
	}
	
	public function change_language(){
		if(isset($_GET['lang_code'])){
			$lang_code = $_GET['lang_code'];
			$languages = $this->registry->get('language');
			if(!empty($languages)){
				$dataLangCode = array();
				foreach($languages as $lang){
					$dataLangCode[] = $lang['lang_code'];
				}

				if($lang_code != "" && in_array($lang_code, $dataLangCode)){
					$data_ses=array(
						"language" => $lang_code,
					);
					$this->session->set_userdata($data_ses);

					if(isset($_GET['current_url'])){
						$current_url = $_GET['current_url'];
						if($current_url != ""){
							redirect($current_url, 'refresh');
						}else{
							redirect(base_url(), 'refresh');
						}
					}else{
						redirect(base_url(), 'refresh');
					}
				}
			}
		}
		$this->show404();
	}
}